/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author maynoigi
 */
@Entity
@Table(name = "Complaint")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Complaint.findAll", query = "SELECT c FROM Complaint c Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintID", query = "SELECT c FROM Complaint c WHERE c.complaintID = :complaintID Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintTitle", query = "SELECT c FROM Complaint c WHERE c.complaintTitle = :complaintTitle Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintContent", query = "SELECT c FROM Complaint c WHERE c.complaintContent = :complaintContent Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintCreateDate", query = "SELECT c FROM Complaint c WHERE c.complaintCreateDate = :complaintCreateDate Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintCloseDate", query = "SELECT c FROM Complaint c WHERE c.complaintCloseDate = :complaintCloseDate Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintStatus", query = "SELECT c FROM Complaint c WHERE c.complaintStatus = :complaintStatus Order by c.complaintID DESC"),
    @NamedQuery(name = "Complaint.findByComplaintPriority", query = "SELECT c FROM Complaint c WHERE c.complaintPriority = :complaintPriority Order by c.complaintID DESC")})
public class Complaint implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "ComplaintID")
    private Integer complaintID;
    @Size(max = 500)
    @Column(name = "ComplaintTitle")
    private String complaintTitle;
    @Size(max = 2147483647)
    @Column(name = "ComplaintContent")
    private String complaintContent;
    @Column(name = "ComplaintCreateDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date complaintCreateDate;
    @Column(name = "ComplaintCloseDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date complaintCloseDate;
    @Column(name = "ComplaintStatus")
    private Integer complaintStatus;
    @Size(max = 200)
    @Column(name = "ComplaintPriority")
    private String complaintPriority;
    @JoinColumn(name = "complaintTechnical", referencedColumnName = "MembersID")
    @ManyToOne
    private Members complaintTechnical;
    @JoinColumn(name = "MembersID", referencedColumnName = "MembersID")
    @ManyToOne
    private Members membersID;
    @JoinColumn(name = "DepartmentID", referencedColumnName = "DepartmentID")
    @ManyToOne
    private Department departmentID;
    @JoinColumn(name = "CategoryID", referencedColumnName = "CategoryID")
    @ManyToOne
    private Category categoryID;
    @OneToMany(mappedBy = "complaintID")
    private Collection<Solution> solutionCollection;

    public Complaint() {
    }

    public Complaint(Integer complaintID) {
        this.complaintID = complaintID;
    }

    public Integer getComplaintID() {
        return complaintID;
    }

    public void setComplaintID(Integer complaintID) {
        this.complaintID = complaintID;
    }

    public String getComplaintTitle() {
        return complaintTitle;
    }

    public void setComplaintTitle(String complaintTitle) {
        this.complaintTitle = complaintTitle;
    }

    public String getComplaintContent() {
        return complaintContent;
    }

    public void setComplaintContent(String complaintContent) {
        this.complaintContent = complaintContent;
    }

    public Date getComplaintCreateDate() {
        return complaintCreateDate;
    }

    public void setComplaintCreateDate(Date complaintCreateDate) {
        this.complaintCreateDate = complaintCreateDate;
    }

    public Date getComplaintCloseDate() {
        return complaintCloseDate;
    }

    public void setComplaintCloseDate(Date complaintCloseDate) {
        this.complaintCloseDate = complaintCloseDate;
    }

    public Integer getComplaintStatus() {
        return complaintStatus;
    }

    public void setComplaintStatus(Integer complaintStatus) {
        this.complaintStatus = complaintStatus;
    }

    public String getComplaintPriority() {
        return complaintPriority;
    }

    public void setComplaintPriority(String complaintPriority) {
        this.complaintPriority = complaintPriority;
    }

    public Members getComplaintTechnical() {
        return complaintTechnical;
    }

    public void setComplaintTechnical(Members complaintTechnical) {
        this.complaintTechnical = complaintTechnical;
    }

    public Members getMembersID() {
        return membersID;
    }

    public void setMembersID(Members membersID) {
        this.membersID = membersID;
    }

    public Department getDepartmentID() {
        return departmentID;
    }

    public void setDepartmentID(Department departmentID) {
        this.departmentID = departmentID;
    }

    public Category getCategoryID() {
        return categoryID;
    }

    public void setCategoryID(Category categoryID) {
        this.categoryID = categoryID;
    }

    @XmlTransient
    public Collection<Solution> getSolutionCollection() {
        return solutionCollection;
    }

    public void setSolutionCollection(Collection<Solution> solutionCollection) {
        this.solutionCollection = solutionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (complaintID != null ? complaintID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Complaint)) {
            return false;
        }
        Complaint other = (Complaint) object;
        if ((this.complaintID == null && other.complaintID != null) || (this.complaintID != null && !this.complaintID.equals(other.complaintID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Complaint[ complaintID=" + complaintID + " ]";
    }
}
